home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 399 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.9 KB

  1. From: fjh@cs.mu.OZ.AU
  2. Message-ID: <fjh-960221-214414@cs.mu.oz.au>
  3. X-Original-Date: Mon, 19 Feb 1996 05:42:05 GMT
  4. Path: in2.uu.net!bounce-back
  5. Date: 21 Feb 96 10:43:43 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Organization: -
  8. Newsgroups: comp.std.c++
  9. Return-Path: <fjh@cs.mu.OZ.AU>
  10. Subject: Re: standardizing routines without main()
  11. References: <4fvmd1$bh1@syn.cs.cornell.edu>
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBFAgUBMSr3yOEDnX0m9pzZAQHurAF/UT5U949x4zfEpHfwEdSFMo/qJRmIQrMC
  14.     q/fA/OvE+UNBxe0jgC2reLKf1iREdRmD
  15.     =SNP2
  16.  
  17. vavasis@CS.Cornell.EDU (Stephen Vavasis) writes:
  18.  
  19. >I would like to propose that the standard deal with the following
  20. >issue.  I would like to write a subroutine in C++ that gets called by
  21. >an existing program.  The subroutine might get loaded with a dynamic
  22. >loader into an already compiled program to which I, the C++
  23. >programmer, have no access.  I imagine other people have the same
  24. >situation.
  25. >
  26. >In this case, there is no C++ main().  Nonetheless, I would still like
  27. >to use C++ features like global static data items whose constructors
  28. >and destructors get called.
  29. >
  30. >To handle this, I would like to be able to put an explicit call like
  31. >"cpp_start()" at the entry point of the routine, and "cpp_finish()" at
  32. >the end that would take care of all the initialization/cleanup C++
  33. >normally does in main.  
  34. [...]
  35. >But as far as I know, the names of these start/finish calls are not
  36. >standardized, so I can't count on portability.
  37.  
  38. I think this is a good idea.  I would just like to forestall any
  39. possible objection that this is something that can't be standandized by
  40. pointing out that the Ada-95 standard deals with the issue.  It uses
  41. the names "adainit" and "adafinal".
  42.  
  43. | B.1 Interfacing Pragmas
  44. |       Implementation Advice
  45. |       
  46. |    (39)
  47. |           If an implementation supports pragma Export to a given
  48. |           language, then it should also allow the main subprogram to be
  49. |           written in that language. It should support some mechanism for
  50. |           invoking the elaboration of the Ada library units included in
  51. |           the system, and for invoking the finalization of the
  52. |           environment task. On typical systems, the recommended mechanism
  53. |           is to provide two subprograms whose link names are "adainit"
  54. |           and "adafinal". Adainit should contain the elaboration code for
  55. |           library units. Adafinal should contain the finalization code.
  56. |           These subprograms should have no effect the second and
  57. |           subsequent time they are called.
  58.  
  59. --
  60. Fergus Henderson                 WWW: http://www.cs.mu.oz.au/~fjh
  61. fjh@cs.mu.oz.au                  PGP: finger fjh@128.250.37.3
  62. ---
  63. [ To submit articles: try just posting with your news-reader.
  64.                       If that fails, use mailto:std-c++@ncar.ucar.edu
  65.   FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
  66.   Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
  67.   Comments? mailto:std-c++-request@ncar.ucar.edu.
  68. ]
  69.